Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix namespacing on kubernetes_priority_class #682

Merged
merged 1 commit into from
Nov 11, 2019

Conversation

alexsomesan
Copy link
Member

Fixes #680.

Although kubernetes_priority_class is a non-namespaced resource and it's schema correctly configures it like that, in the original implementation the CRUD functions where attempting to assemble a namespaced resource ID and this led to import functionality not behaving as expected.

Tests pass.

~/workspace/terraform-provider-kubernetes(priority-class-review*) » make testacc TESTARGS="-run '^TestAccKubernetesPriorityClass_'"                                                            alex@MacBook-Pro
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test "./kubernetes" -v -run '^TestAccKubernetesPriorityClass_' -timeout 120m
=== RUN   TestAccKubernetesPriorityClass_basic
--- PASS: TestAccKubernetesPriorityClass_basic (1.32s)
=== RUN   TestAccKubernetesPriorityClass_generatedName
--- PASS: TestAccKubernetesPriorityClass_generatedName (0.56s)
=== RUN   TestAccKubernetesPriorityClass_importBasic
--- PASS: TestAccKubernetesPriorityClass_importBasic (0.67s)
PASS
ok  	github.com/terraform-providers/terraform-provider-kubernetes/kubernetes	7.937s
------------------------------------------------------------

Import works

~/test-680 » cat main.tf
resource "kubernetes_priority_class" "system-node-critical" {
  metadata {
    name = "system-node-critical"
  }
} 
------------------------------------------------------------
~/test-680 » terraform import kubernetes_priority_class.system-node-critical system-node-critical
kubernetes_priority_class.system-node-critical: Importing from ID "system-node-critical"...
kubernetes_priority_class.system-node-critical: Import prepared!
  Prepared kubernetes_priority_class for import
kubernetes_priority_class.system-node-critical: Refreshing state... [id=system-node-critical]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

------------------------------------------------------------
~/test-680 » terraform state show kubernetes_priority_class.system-node-critical
# kubernetes_priority_class.system-node-critical:
resource "kubernetes_priority_class" "system-node-critical" {
    description    = "Used for system critical pods that must not be moved from their current node."
    global_default = false
    id             = "system-node-critical"
    value          = 2000001000

    metadata {
        annotations      = {}
        generation       = 1
        labels           = {}
        name             = "system-node-critical"
        resource_version = "40"
        self_link        = "/apis/scheduling.k8s.io/v1/priorityclasses/system-node-critical"
        uid              = "ca8ed131-97fd-4657-9d4c-eca6f8af1eaa"
    }
}
------------------------------------------------------------

@alexsomesan alexsomesan requested a review from a team November 11, 2019 12:04
@ghost ghost added the size/S label Nov 11, 2019
Copy link

@koikonom koikonom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@alexsomesan alexsomesan merged commit 40db953 into master Nov 11, 2019
@dsymonds
Copy link
Contributor

Note that this'll break anyone using this resource under the old namespaced name. It's straightforward to deal with (terraform state rm on the old name, then re-import), but it seems like this should be called out in the release notes.

@alexsomesan alexsomesan deleted the priority-class-review branch February 10, 2020 14:45
@ghost ghost locked and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubernetes_priority_class import incorrectly requires a namespace
3 participants